﻿CREATE PROCEDURE [config].[GetMailBoxes](
	@ServerMailBox NVARCHAR (100) OUTPUT,
	@DBAMailBox NVARCHAR (100) OUTPUT
)
AS
BEGIN
	SET NOCOUNT ON

	DECLARE @RC int
	SET @RC = 0

	SET @ServerMailBox = config.GetServerMailBox()
	IF(@ServerMailBox IS NULL)
		BEGIN
			RAISERROR('A SQL Agent Operator must exist for the SQL Server Service account called "SQLService".
Please add the operator and try again.',16,1)
			SET @RC = @@ERROR
		END

	SELECT @DBAMailBox = config.GetDBAMailBox()
	IF(@DBAMailBox IS NULL)
		BEGIN
			RAISERROR('A SQL Agent Operator must exist for the Database Administrator called "DBA".
Please add the operator and try again.',16,1)
			SET @RC = @@ERROR
		END

	RETURN(@RC)
END